<?php

/**
 * @author FROSTY (valik619)
 * @site nadmad.ru
 * @mail valik619@inbox.ru
 */
  
$title = 'Other';
 include('system/core.php');
include('system/head.php');

$case=htmlspecialchars(trim($_GET['a']));

switch($case){

default:

 /*Статистика*/
 
 $cat = mysql_result(mysql_query("SELECT count(*) FROM `cat`"), 0);
 
 $post = mysql_result(mysql_query("SELECT count(*) FROM `posts`"), 0);

 $users = mysql_result(mysql_query("SELECT count(*) FROM `users`"), 0);

 $new_posts = mysql_result(mysql_query("SELECT count(*) FROM `posts` WHERE `time` > '".(time()-3600*24)."'"), 0);

  $new_users = mysql_result(mysql_query("SELECT count(*) FROM `users` WHERE `reg_time` > '".(time()-3600*24)."'"), 0);
  
  $online_users = mysql_result(mysql_query("SELECT count(*) FROM `users` WHERE `online` > '".(time()-300)."'"), 0);
  
echo '<div class="title">'.$lang['stat'].'</div>';

echo '<div class="small"><a class="url" href="other.php?a=categories">'.$lang['categories'].': '.$cat.'</a></div>';
echo '<div class="small"><a class="url" href="other.php?a=lastpost">'.$lang['posts'].': '.$post.' (+'.$new_posts.')</a></div>';
echo '<div class="small"><a class="url" href="users.php">'.$lang['users'].': '.$users.' (+'.$new_users.')</a></div>';
echo '<div class="small"><a class="url" href="other.php?a=online">Online: '.$online_users.'</a></div>';
break;

case 'categories':


$categories=mysql_query("SELECT * FROM `cat` ORDER BY `order`");

while($row=mysql_fetch_assoc($categories)){
    echo '<div class="title"><a href="cat/index.php?id='.$row['id'].'">'.$row['name'].'</a></div>';
    echo '<div class="small">'.$row['soft'].'</div>';
    $posts=mysql_query("SELECT * FROM `posts` WHERE `catid` = '$row[id]' ORDER BY `time` DESC LIMIT 3");
    while($post=mysql_fetch_assoc($posts)){  
        
    echo '<div class="small"><a class="url" href="posts/index.php?id='.$post['id'].'">'.$post['name'].'</a></div>';
    
    }
    
    };

 echo '<div class="small"><a class="url" href="other.php">'.$lang['back'].'</a></div>';
break;

case "lastpost":

echo '<div class="title">'.$lang['lastpost'].'</div>';
$total=mysql_result(mysql_query("SELECT count(*) FROM `posts`"), 0);
    //Моя навигация
    $page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ; 
    $allpage = ceil($total/$kmess);
    $start = $page*$kmess - $kmess; 

$posts=mysql_query("SELECT * FROM `posts` ORDER BY `time` DESC LIMIT $start,$kmess");


while($row=mysql_fetch_assoc($posts)){
    echo '<div class="small"><a class="url" href="posts/index.php?id='.$row['id'].'">'.$row['name'].'</a>';

      echo '<p>'.functions::bbcode(substr($row['text'],0,150)).'</p><br /><a href="comments/index.php?id='.$row['id'].'">'.$lang['comments'].'</a></div>';
      

    };
    
    if($total>$kmess){
    echo '<p>';
    functions::navigation($allpage,"other.php?a=lastpost&amp;p={p}",1);  
echo '</p>';}

 echo '<div class="title"><a href="other.php">'.$lang['back'].'</a></div>';
break;

case 'online':

//получаем данные о пользователе
$all = mysql_query("SELECT * FROM `users` WHERE `online` > ".(time()-300)."");

echo '<div class="title">'.$lang['users1'].' Online</div>';

    //Моя навигация
    $page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ; 
    $allpage = ceil(mysql_num_rows($all)/$kmess);
    $start = $page*$kmess - $kmess; 
$all = mysql_query("SELECT * FROM `users` WHERE `online` > ".(time()-300)." LIMIT $start,$kmess");

while ($users = mysql_fetch_assoc($all)){
    
    $reg = ceil ( (time() - $users[reg_time])/(3600*24) );

$n=$users;


    echo '<div class="small"><a class="url" href="'.$root.'/office.php?a=anketa&amp;id='.$n['id'].'">';
            echo '<div class="comm_author">';
        echo "<div class='like'><img class='limgcom' src='".functions::ava(''.$n['mail'].'', 64, 'g', 'mm')."' alt='Gravatar'></div>";
        echo '<div class="info" style="font-size: 18px;"><b>'.$n['nick'].'</b></div>';
        echo '<small>';
        echo ''.$lang['reg_time'].' ';
echo $reg; 
echo ' '.$lang['doba'].' <br>';
        echo '</small>';
        if($n['rights'] == 0){
        echo '<span class="green">'.$lang['users2'].'</span>';
        }else{
        echo '<span class="red">'.$lang['admin'].'</span>';    
        }
        echo '</a></div></div>';


}
$all = mysql_query("SELECT * FROM `users` WHERE `online` > ".(time()-300)."");
$total = mysql_num_rows($all);
    if($total>$kmess){
    echo '<p>';
    functions::navigation($allpage,"other.php?a=online&amp;p={p}",1);  
echo '</p>';}

echo '</div>'; //imenu
echo '<div class="title"><a href="http://'.$set['home'].'">'.$lang['back'].'</a></div>';

break;

}

include('system/foot.php');

/**
 * @author FROSTY (valik619)
 * @site nadmad.ru
 * @mail valik619@inbox.ru
 */

?>